﻿using System;
using System.Reflection;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Dynamic;
using System.ComponentModel;
using EIIS.Infrastructure.Model.System.Authority;
using EIIS.Infrastructure.Service.System.Authority;
using EIIS.Infrastructure.Repositories.System.Authority;


namespace EIIS.Infrastructure.Service.Implement
{
    public class MenuManager:GenericManagerBase<MenuNode>,IMenuManager
    {
        public bool IsExistWithName(string strName, string strId, string strWhere)
        {
            return ((IMenuRepository)(this.CurrentRepository)).IsFieldExist("Name", strName, strId, strWhere);
        }

        public bool IsExistWithTreeCode(string strTreeCode, string strId, string strWhere)
        {
            return ((IMenuRepository)(this.CurrentRepository)).IsFieldExist("TreeCode", strTreeCode, strId, strWhere);
        }

        public bool HasChild(string strId)
        {
            return ((IMenuRepository)(this.CurrentRepository)).HasChild(strId);
        }

        public MenuNode CreateRoot()
        {
            MenuNode root = new MenuNode();
            root.Name = "所有菜单";
            root.Id = "0";
            root.ParentId = string.Empty;
            root.TreeCode = "001";
            root.Description = "菜单树的根节点";
            root.Leaf = false;
            root.Index = 0;
            root.Level = 0;
            root.ActionName = string.Empty;
            root.ControllerName = string.Empty;
            root.IconCls = string.Empty;
            root.IsPage = false;
            root.Url = MenuNode.GetURL(root.ControllerName, root.ActionName);

            return root;
        }
    }
}
